#!/bin/bash


check_ip(){
	if ping -c 1 -i 0.1 -w 1  www.baidu.com  &>/dev/null
	then
		echo "this server can go internet"
	else
		read -p "please input ip address :" u_ip
		read -p "please input netmask :" u_netmask
		read -p "please input gateway :" u_gateway
		read -p "please input DNS server :" u_dns_server
		cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=$u_ip
NETMASK=$u_netmask
GATEWAY=$u_gateway
DNS1=$u_dns_server
EOF
	service network restart
	fi
}
#check_ip
check_yum(){
	yum clean all &>/dev/null
	if yum list  
	then
		echo "yum is ok"
	else
		echo "please check /etc/yum.repos.d directory have files ,there files start with Centos"
	fi
	if rpm -q epel-release 
	then
		echo "epel  source is ok"
	else
		wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
		rpm -ivh epel-release-latest-6.noarch.rpm
		echo "epel source is ok"
	fi
	
}
#check_yum
check_mysql_install(){

	if rpm -q mysql mysql-server
	then
		echo "mysql software had been installled"
	else
		yum install mysql mysql-server -y
	fi
}
#check_mysql_install

check_mysql_daemon(){
	if ! service mysqld status
	then
		service mysqld start	
	fi


}
#check_mysql_daemon
check_mysql_passwd(){
	if ! mysql 
	then
		echo "mysql has set password"
	fi
	
}
#check_mysql_passwd
reset_mysql_passwd(){

	read -p "please input old password:" old_pwd
	read -p "please input new password:" new_pwd
	mysqladmin -uroot -p$old_pwd password $new_pwd
}
#reset_mysql_passwd





